/*
 * AskDiagramNameAndType.cpp
 *
 *  Created on: 05/05/2013
 *      Author: juan
 */

#include "gui/SubWindow/AskDiagramNameAndType.h"
#include "gtkmm/stock.h"
#include "utils/constantes.h"

const std::string LABEL_TEXT = "Ingrese el ";

AskDiagramNameAndType::AskDiagramNameAndType(std::string name) : m_label(LABEL_TEXT + name.c_str()) {
    m_dialog.set_title(name.c_str());
    m_dialog.get_vbox()->pack_start( m_label, true, true , 5);
    m_dialog.get_vbox()->pack_start(m_nameEntry, true ,true, 5);


    m_radioButtons[0] = new Gtk::RadioButton(m_radio, "Diagrama de clases");
    m_radioButtons[1] = new Gtk::RadioButton(m_radio, "Diagrama DER");
    m_radioButtons[1]->set_active();

    m_dialog.get_vbox()->pack_start(*m_radioButtons[0], true ,true, 5);
    m_dialog.get_vbox()->pack_start(*m_radioButtons[1], true ,true, 5);


    m_dialog.add_button( Gtk::Stock::OK, Gtk::RESPONSE_OK);
    m_dialog.add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    m_nameEntry.set_activates_default();
    m_dialog.set_response_sensitive(Gtk::RESPONSE_OK);
    m_dialog.set_default_response(Gtk::RESPONSE_OK);
}

AskDiagramNameAndType::~AskDiagramNameAndType() {
}

std::string AskDiagramNameAndType::askName(){
    m_dialog.show_all();
    int res = m_dialog.run();
    if ( res == Gtk::RESPONSE_OK){
        return m_nameEntry.get_text();
    }
    return "";
}

int AskDiagramNameAndType::askType(){
    int retval = 0;
    if(m_radioButtons[0]->get_active())
        retval = DIAGRAMA_CLASES;
    else
        retval = DIAGRAMA_DER;
    return retval;
}
